home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / comm / tcp / AmiMsgWin.lha / amimsgwin / amimsgwin.c < prev    next >
C/C++ Source or Header  |  1993-12-19  |  14KB  |  593 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <stdarg.h>
  4. #include <string.h>
  5. #include <ctype.h>
  6. #include <time.h>
  7. #include <error.h>
  8. #include <netdb.h>
  9.  
  10. #include <libraries/mui.h>
  11. #include <libraries/asl.h>
  12. #include <libraries/gadtools.h>
  13. #include <libraries/multiuser.h>
  14. #include <libraries/asl.h>
  15. #include <libraries/iffparse.h>
  16. #include <libraries/multiuser.h>
  17.  
  18. #include <proto/dos.h>
  19. #include <proto/exec.h>
  20. #include <proto/intuition.h>
  21. #include <proto/muimaster.h>
  22. #include <proto/asl.h>
  23. #include <proto/multiuser.h>
  24.  
  25. #define StringSucc(win,fromg,tog)\
  26.     DoMethod(fromg,MUIM_Notify,MUIA_String_Acknowledge,MUIV_EveryTime,\
  27.     win,3,MUIM_Set,MUIA_Window_ActiveObject,tog)
  28. #define SetButtonID(app,butobj,id)\
  29.     DoMethod(butobj,MUIM_Notify,MUIA_Pressed,FALSE,\
  30.         app,2,MUIM_Application_ReturnID,id)
  31. #define GetString(strobj,tostr,tempptr)\
  32.     { get(strobj,MUIA_String_Contents,&tempptr);\
  33.       strcpy(tostr,tempptr); }
  34. #define Text TextObject,TextFrame,End
  35.  
  36. char VersionTag[]="\0$VER: JoranAmimsgWin 0.1 (14.12.93)";
  37.  
  38. struct Library *MUIMasterBase;
  39. struct muBase *muBase;
  40.  
  41. struct AmiMsg {
  42.     struct MinNode am_Node;
  43.     char *am_user;
  44.     char *am_host;
  45.     char *am_msg;
  46.     struct sockaddr_in am_addr;
  47.     time_t am_time;
  48. };
  49.  
  50. struct AmiMsgMsg {
  51.     struct Message amm_Msg;
  52.     struct AmiMsg amm_AmiMsg;
  53. };
  54.  
  55. #define PORTNAME "JoranAmiMsgWin"
  56.     
  57. struct MinList MsgList;
  58. struct MsgPort *MyPort;
  59. ULONG MyPortSig;
  60. struct AmiMsg *InfoAmiMsg;
  61.  
  62. enum {
  63.     ShowInfo_ID=1,
  64.     InfoReply_ID,
  65.     MainReply_ID,
  66.     MainSend_ID,
  67.     SendClose_ID,
  68.     SendHostAck_ID,
  69.     SendSend_ID,
  70.     ClearList_ID,
  71.     SendUser_ID
  72. };
  73.  
  74. char buf[1024];
  75. char hostname[128];
  76.  
  77. APTR App;
  78. APTR MainWin;
  79. APTR AmiMsgList,AmiMsgListview,InfoBut,InfoIp;
  80. APTR MainQuit,ClearList;
  81. APTR SendBut,ReplyBut;
  82. APTR InfoWin;
  83. APTR InfoName,InfoMsg,InfoOkBut,InfoTime;
  84. APTR InfoReplyBut;
  85. APTR SendWin;
  86. APTR SendHost,SendIp,SendMsg;
  87. APTR SendCancel,SendSend,SendFrom;
  88.  
  89. long gethostname(char *,long len);
  90. ULONG __asm __saveds MsgMultiHookFunc(register __a1 struct AmiMsg *,register __a2 char **);
  91. struct Hook MsgMultiHook={0,0,MsgMultiHookFunc,0,0};
  92.  
  93. ULONG __asm __saveds MsgMultiHookFunc(register __a1 struct AmiMsg *am,register __a2 char **cols)
  94. {
  95.     cols[0]=am->am_user;
  96.     cols[1]="@";
  97.     cols[2]=am->am_host;
  98.     cols[3]=am->am_msg;
  99.  
  100.     return 0;
  101. }
  102.  
  103. void FreeAmiMsg(struct AmiMsg *Msg)
  104. {
  105.     if(!Msg) return;
  106.     if(Msg->am_user) FreeMem(Msg->am_user,strlen(Msg->am_user)+1);
  107.     if(Msg->am_host) FreeMem(Msg->am_host,strlen(Msg->am_host)+1);
  108.     if(Msg->am_msg) FreeMem(Msg->am_msg,strlen(Msg->am_msg)+1);
  109.     FreeMem(Msg,sizeof(struct AmiMsg));
  110. }
  111.  
  112. struct AmiMsg *CopyFromAmiMsgMsg(struct AmiMsgMsg *Msg)
  113. {
  114.     struct AmiMsg *am;
  115.     
  116.     if(am=AllocMem(sizeof(struct AmiMsg),MEMF_ANY|MEMF_CLEAR))
  117.     {
  118.         if(am->am_user=AllocMem(strlen(Msg->amm_AmiMsg.am_user)+1,MEMF_ANY))
  119.         {
  120.             strcpy(am->am_user,Msg->amm_AmiMsg.am_user);
  121.                               
  122.             if(am->am_host=AllocMem(strlen(Msg->amm_AmiMsg.am_host)+1,MEMF_ANY))
  123.             {
  124.                 strcpy(am->am_host,Msg->amm_AmiMsg.am_host);
  125.             
  126.                 if(am->am_msg=AllocMem(strlen(Msg->amm_AmiMsg.am_msg)+1,MEMF_ANY))
  127.                 {
  128.                     strcpy(am->am_msg,Msg->amm_AmiMsg.am_msg);
  129.                     
  130.                     memcpy(&am->am_addr,&Msg->amm_AmiMsg.am_addr,sizeof(struct sockaddr_in));
  131.                     am->am_time=Msg->amm_AmiMsg.am_time;
  132.                     
  133.                     return am;
  134.                 }
  135.             }
  136.         }
  137.     }
  138.     
  139.     FreeAmiMsg(am);
  140.     
  141.     return NULL;
  142. }
  143.  
  144. char *InitAll(void)
  145. {
  146.     struct MsgPort *OtherPort;
  147.     
  148.     NewList((struct List *)&MsgList);
  149.     
  150.     Forbid();
  151.     OtherPort=FindPort(PORTNAME);
  152.     if(!OtherPort) MyPort=CreatePort(PORTNAME,0);
  153.     Permit();
  154.  
  155.     if(OtherPort) return "Program is already running.";
  156.     if(!MyPort) return "Error creating port";
  157.     
  158.     MyPortSig=1<<MyPort->mp_SigBit;
  159.     
  160.     return NULL;
  161. }
  162.  
  163. void CloseAll(void)
  164. {
  165.     struct AmiMsg *am;
  166.     
  167.     if(MyPort)
  168.     {
  169.         Forbid();
  170.         while(GetMsg(MyPort));
  171.         DeletePort(MyPort);
  172.         Permit();
  173.  
  174.         while(!IsListEmpty((struct List *)&MsgList))
  175.         {
  176.             am=(struct AmiMsg *)MsgList.mlh_Head;
  177.             Remove((struct Node *)am);
  178.             FreeAmiMsg(am);
  179.         }
  180.     }
  181.     if(MUIMasterBase) CloseLibrary((struct Library *)MUIMasterBase);
  182.     if(muBase) CloseLibrary((struct Library *)muBase);
  183. }
  184.  
  185. struct AmiMsg *GetSelAmiMsg(void)
  186. {
  187.     ULONG pos;
  188.     struct AmiMsg *am;
  189.     
  190.     get(AmiMsgList,MUIA_List_Active,&pos);
  191.     if(pos==MUIV_List_Active_Off) return NULL;
  192.     
  193.     for(am=(struct AmiMsg *)MsgList.mlh_Head;am!=(struct AmiMsg *)&MsgList.mlh_Tail;am=(struct AmiMsg *)am->am_Node.mln_Succ)
  194.         if(!(pos--)) break;
  195.     
  196.     return am;
  197. }
  198.  
  199. void DoShowInfo(void)
  200. {
  201.     struct AmiMsg *am;
  202.     
  203.     if(!(am=GetSelAmiMsg())) return;
  204.     InfoAmiMsg=am;
  205.         
  206.     strcpy(buf,am->am_user);strcat(buf,"@");strcat(buf,am->am_host);
  207.     set(InfoName,MUIA_Text_Contents,buf);
  208.     set(InfoIp,MUIA_Text_Contents,inet_ntoa(am->am_addr.sin_addr));
  209.     strcpy(buf,ctime(&am->am_time));*strchr(buf,'\n')='\0';
  210.     set(InfoTime,MUIA_Text_Contents,buf);
  211.     set(InfoMsg,MUIA_Floattext_Text,am->am_msg);
  212.     
  213.     set(InfoWin,MUIA_Window_Open,TRUE);
  214.     
  215. }
  216.  
  217. void errorreq(char *fmt)
  218. {
  219.     MUI_Request(App,MainWin,0,"JoranAmiMsgWin","Hmmm",
  220.         fmt
  221.     );
  222. }
  223.  
  224. void perrorreq(char *fmt)
  225. {
  226.     MUI_Request(App,MainWin,0,"JoranAmiMsgWin","Hmmm",
  227.         "%s: %s",fmt,strerror(errno)
  228.     );
  229. }
  230.  
  231. void DoSend(struct AmiMsg *am)
  232. {
  233.     BOOL running=TRUE;
  234.     struct sockaddr_in server;
  235.     struct hostent *hp=NULL;
  236.     struct muUserInfo *UserInfo;
  237.     
  238.     set(App,MUIA_Application_Sleep,TRUE);
  239.     
  240.     if(muBase)
  241.     {
  242.         if(UserInfo=muAllocUserInfo())
  243.         {
  244.             UserInfo->uid=(muGetTaskOwner(NULL)&muMASK_UID)>>16;
  245.             if(muGetUserInfo(UserInfo,muKeyType_uid))
  246.                 set(SendFrom,MUIA_Text_Contents,UserInfo->UserID);
  247.             else
  248.                 set(SendFrom,MUIA_Text_Contents,"unknown");
  249.             muFreeUserInfo(UserInfo);
  250.         } else set(SendFrom,MUIA_Text_Contents,"unknown");
  251.     }
  252.     
  253.     if(am)
  254.     {
  255.         set(SendHost,MUIA_String_Contents,am->am_host);
  256.         set(SendIp,MUIA_Text_Contents,inet_ntoa(am->am_addr.sin_addr));
  257.         set(SendMsg,MUIA_String_Contents,"");
  258.     }
  259.     else
  260.     {
  261.         set(SendHost,MUIA_String_Contents,"");
  262.         set(SendIp,MUIA_Text_Contents,"");
  263.         set(SendMsg,MUIA_String_Contents,"");    
  264.     }
  265.     set(SendWin,MUIA_Window_Open,TRUE);
  266.     if(!muBase) set(SendWin,MUIA_Window_ActiveObject,SendFrom);
  267.     else
  268.     {
  269.         if(am) set(SendWin,MUIA_Window_ActiveObject,SendMsg);
  270.         else set(SendWin,MUIA_Window_ActiveObject,SendHost);
  271.     }
  272.     
  273.     while(running)
  274.     {
  275.         ULONG sigs;
  276.         
  277.         switch(DoMethod(App,MUIM_Application_Input,&sigs))
  278.         {
  279.             char *host;
  280.             struct in_addr ia;
  281.             struct servent *sp;
  282.             char *msg,*from;
  283.             int s;
  284.             
  285.             case MUIV_Application_ReturnID_Quit:
  286.                 running=FALSE;
  287.                 DoMethod(App,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  288.                 break;
  289.             case SendClose_ID:
  290.                 running=FALSE;
  291.                 break;
  292.             case SendHostAck_ID:
  293.                 get(SendHost,MUIA_String_Contents,&host);
  294.                 if(!*host) hp=gethostbyname("localhost");
  295.                 else hp=gethostbyname(host);
  296.                 if(hp)
  297.                 {
  298.                     memcpy((char *)&ia,hp->h_addr,hp->h_length);
  299.                     set(SendIp,MUIA_Text_Contents,inet_ntoa(ia));
  300.                     set(SendWin,MUIA_Window_ActiveObject,SendMsg);
  301.                 }
  302.                 else
  303.                 {
  304.                     set(SendIp,MUIA_Text_Contents,"unknown host..");
  305.                     set(SendWin,MUIA_Window_ActiveObject,SendHost);
  306.                 }
  307.                 break;
  308.             case SendUser_ID:
  309.                 if(am) set(SendWin,MUIA_Window_ActiveObject,SendMsg);
  310.                 else set(SendWin,MUIA_Window_ActiveObject,SendHost);
  311.                 break;
  312.             case SendSend_ID:
  313.                 gethostname(hostname,sizeof(hostname));
  314.                 sp=getservbyname("amimsg","tcp");
  315.                 if(sp==NULL)
  316.                     errorreq("unknown service");
  317.                 else
  318.                 {
  319.                     if(!hp && !am)
  320.                     {
  321.                         errorreq("unknown host");
  322.                         break;
  323.                     }
  324.  
  325.                     bzero((char *)&server,sizeof(server));
  326.                     if(hp)
  327.                     {
  328.                         bcopy(hp->h_addr,(char *)&server.sin_addr,hp->h_length);
  329.                         server.sin_family=hp->h_addrtype;
  330.                     }
  331.                     else bcopy(&am->am_addr,&server,sizeof(server));
  332.                     server.sin_port=sp->s_port;
  333.                     
  334.                     s=socket(AF_INET,SOCK_STREAM,0);
  335.                     if(s<0)
  336.                         perrorreq("socket");
  337.                     else
  338.                     {
  339.                         set(SendWin,MUIA_Window_Sleep,TRUE);
  340.                         if(connect(s,(struct sockaddr *)&server,sizeof(server))<0)
  341.                             perrorreq("connect");
  342.                         else
  343.                         {
  344.                             get(SendMsg,MUIA_String_Contents,&msg);
  345.                             if(muBase) get(SendFrom,MUIA_Text_Contents,&from);
  346.                             else get(SendFrom,MUIA_String_Contents,&from);
  347.                             if(!*from) from="unknown";
  348.                             sprintf(buf,
  349.                                 "HOST %s\n"
  350.                                 "USER %s\n"
  351.                                 "MSG %s\n",
  352.                                 hostname,
  353.                                 from,
  354.                                 msg
  355.                             );
  356.                             send(s,buf,strlen(buf),0);
  357.                         }
  358.                         set(SendWin,MUIA_Window_Sleep,FALSE);
  359.                         CloseSocket(s);
  360.                     }
  361.                 }
  362.                 running=FALSE;
  363.                 break;
  364.         }
  365.         if (running && sigs) Wait(sigs);
  366.     }
  367.     
  368.     set(SendWin,MUIA_Window_Open,FALSE);
  369.     set(App,MUIA_Application_Sleep,FALSE);
  370. }
  371.  
  372. void DoClearList(void)
  373. {
  374.     struct AmiMsg *am;
  375.     
  376.     set(InfoWin,MUIA_Window_Open,FALSE);
  377.     DoMethod(AmiMsgList,MUIM_List_Clear);
  378.     while(!IsListEmpty((struct List *)&MsgList))
  379.     {
  380.         am=(struct AmiMsg *)MsgList.mlh_Head;
  381.         Remove((struct Node *)am);
  382.         FreeAmiMsg(am);
  383.     }
  384. }
  385.  
  386. void main(int argc)
  387. {
  388.     BOOL running=TRUE;
  389.     char *errmsg;
  390.     
  391.     atexit(CloseAll);
  392.     if(!(MUIMasterBase=OpenLibrary(MUIMASTER_NAME,MUIMASTER_VMIN))) exit(20);
  393.     muBase=(struct muBase *)OpenLibrary(MULTIUSERNAME,MULTIUSERVERSION);
  394.         
  395.     App = ApplicationObject,
  396.         MUIA_Application_Title,        "AmiMsgWin",
  397.         MUIA_Application_Version,    "$VER: JoranAmiMsgWin 0.1 (16.12.93)",
  398.         MUIA_Application_Copyright,"©1993 by Joran Jessurun",
  399.         MUIA_Application_Author,    "Joran Jessurun",
  400.         MUIA_Application_Base,        "AMIMSGWIN",
  401.         MUIA_Application_Description,"GUI for JoranAmiMsg",
  402.         SubWindow, MainWin=WindowObject,
  403.             MUIA_Window_Title,        "AmiMsgWin V0.1",
  404.             MUIA_Window_ID,            MAKE_ID('M','A','I','N'),
  405.             WindowContents,
  406.             VGroup, 
  407.                 Child, AmiMsgListview=ListviewObject,
  408.                     MUIA_Listview_List, AmiMsgList=ListObject,
  409.                         ReadListFrame,
  410.                         MUIA_List_Format,"DELTA=0,DELTA=0,DELTA=10,",
  411.                         MUIA_List_DisplayHook,&MsgMultiHook,
  412.                     End,
  413.                 End,
  414.                 Child, HGroup,
  415.                     MUIA_Group_SameWidth,TRUE,
  416.                     Child, SendBut=SimpleButton("Send"),
  417.                     Child, ReplyBut=SimpleButton("Reply"),
  418.                     Child, InfoBut=SimpleButton("Info"),
  419.                     Child, ClearList=SimpleButton("Clear List"),
  420.                     Child, MainQuit=SimpleButton("Quit"),
  421.                 End,
  422.             End,
  423.         End,
  424.         SubWindow, InfoWin=WindowObject,
  425.             MUIA_Window_Title,        "Message Info",
  426.             MUIA_Window_ID,            MAKE_ID('M','S','G','I'),
  427.             WindowContents,
  428.             VGroup,
  429.                Child, HGroup,
  430.                    MUIA_Group_Columns,2,
  431.                    Child, Label1("name:"),
  432.                    Child, InfoName=Text,
  433.                    Child, Label1("ip:"),
  434.                    Child, InfoIp=Text,
  435.                    Child, Label1("time:"),
  436.                    Child, InfoTime=Text,
  437.                End,
  438.                 Child, HGroup,
  439.                     Child, VGroup,
  440.                         Child, Label1("message:"),
  441.                         Child, VSpace(0),
  442.                     End,
  443.                     Child,InfoMsg=FloattextObject,
  444.                         TextFrame,
  445.                     End,
  446.                 End,
  447.                 Child, HGroup,
  448.                     MUIA_Group_SameWidth,TRUE,
  449.                     Child, InfoOkBut=SimpleButton("Ok"),
  450.                     Child, HSpace(0),
  451.                     Child, InfoReplyBut=SimpleButton("Reply"),
  452.                 End,
  453.             End,
  454.         End,
  455.         SubWindow, SendWin=WindowObject,
  456.             MUIA_Window_Title,        "Send Message",
  457.             MUIA_Window_ID,            MAKE_ID('S','M','S','G'),
  458.             WindowContents,
  459.             VGroup,
  460.                 Child, HGroup,
  461.                     MUIA_Group_Columns,2,
  462.                     Child, Label2("from:"),
  463.                     Child, SendFrom=muBase?Text:String("",20),
  464.                     Child, Label2("host:"),
  465.                     Child, SendHost=String("",255),
  466.                     Child, Label1("ip:"),
  467.                     Child, SendIp=Text,
  468.                     Child, Label2("msg:"),
  469.                     Child, SendMsg=String("",255),
  470.                 End,
  471.                 Child, HGroup,
  472.                     MUIA_Group_SameWidth,TRUE,
  473.                     Child, SendSend=SimpleButton("Send"),
  474.                     Child, HSpace(0),
  475.                     Child, SendCancel=SimpleButton("Cancel"),
  476.                 End,
  477.             End,
  478.         End,
  479.     End;
  480.  
  481.     if(!App)
  482.     {
  483.         MUI_Request(NULL,NULL,0,"AmiMsgWin V0.1","Hmmm",
  484.             "Error initialising program."
  485.         );
  486.         exit(20);
  487.     }
  488.     
  489.     // Install notify's to main program
  490.     DoMethod(MainWin,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,
  491.         App,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  492.     SetButtonID(App,InfoBut,ShowInfo_ID);
  493.     DoMethod(AmiMsgListview,MUIM_Notify,MUIA_Listview_DoubleClick,TRUE,
  494.         App,2,MUIM_Application_ReturnID,ShowInfo_ID);
  495.     DoMethod(InfoWin,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,
  496.         InfoWin,3,MUIM_Set,MUIA_Window_Open,FALSE);
  497.     DoMethod(InfoOkBut,MUIM_Notify,MUIA_Pressed,FALSE,
  498.         InfoWin,3,MUIM_Set,MUIA_Window_Open,FALSE);
  499.     SetButtonID(App,ReplyBut,MainReply_ID);
  500.     SetButtonID(App,SendBut,MainSend_ID);
  501.     SetButtonID(App,InfoReplyBut,InfoReply_ID);
  502.     DoMethod(SendWin,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,
  503.         App,2,MUIM_Application_ReturnID,SendClose_ID);
  504.     DoMethod(SendHost,MUIM_Notify,MUIA_String_Acknowledge,MUIV_EveryTime,
  505.         App,2,MUIM_Application_ReturnID,SendHostAck_ID);
  506.     SetButtonID(App,SendSend,SendSend_ID);
  507.     SetButtonID(App,SendCancel,SendClose_ID);
  508.     DoMethod(SendMsg,MUIM_Notify,MUIA_String_Acknowledge,MUIV_EveryTime,
  509.         App,2,MUIM_Application_ReturnID,SendSend_ID);
  510.     SetButtonID(App,MainQuit,MUIV_Application_ReturnID_Quit);
  511.     SetButtonID(App,ClearList,ClearList_ID);
  512.     if(!muBase)
  513.     {
  514.         DoMethod(SendFrom,MUIM_Notify,MUIA_String_Acknowledge,MUIV_EveryTime,
  515.             App,2,MUIM_Application_ReturnID,SendUser_ID);
  516.     }
  517.     DoMethod(MainWin,MUIM_Window_SetCycleChain,
  518.         AmiMsgListview,SendBut,ReplyBut,InfoBut,
  519.         ClearList,MainQuit,
  520.         NULL);
  521.     DoMethod(InfoWin,MUIM_Window_SetCycleChain,
  522.         InfoOkBut,InfoReplyBut,
  523.         NULL);
  524.     DoMethod(SendWin,MUIM_Window_SetCycleChain,
  525.         SendFrom,SendHost,SendMsg,
  526.         SendSend,SendCancel,
  527.         NULL);
  528.  
  529.     set(MainWin,MUIA_Window_Open,TRUE);
  530.  
  531.     if(errmsg=InitAll())
  532.     {
  533.         MUI_Request(App,MainWin,0,"Error initialising AmiMsgWin","Hmmm",
  534.             errmsg
  535.         );
  536.         running=FALSE;
  537.     }
  538.  
  539.     while (running)
  540.     {
  541.        ULONG signals;
  542.         struct AmiMsgMsg *amm;
  543.  
  544.         while(amm=(struct AmiMsgMsg *)GetMsg(MyPort))
  545.         {
  546.             struct AmiMsg *am;
  547.             
  548.             am=CopyFromAmiMsgMsg(amm);
  549.             ReplyMsg((struct Message *)amm);
  550.             if(am)
  551.             {
  552.                 LONG entries;
  553.                 AddTail((struct List *)&MsgList,(struct Node *)am);
  554.                 DoMethod(AmiMsgList,MUIM_List_Insert,&am,1,MUIV_List_Insert_Bottom);
  555.                 get(AmiMsgList,MUIA_List_Entries,&entries);
  556.                 DoMethod(AmiMsgList,MUIM_List_Jump,entries-1);
  557.             }
  558.         }
  559.  
  560.        switch (DoMethod(App,MUIM_Application_Input,&signals))
  561.        {
  562.             struct AmiMsg *am;
  563.             
  564.             case MUIV_Application_ReturnID_Quit:
  565.                 running = FALSE;
  566.                 break;
  567.             case ShowInfo_ID:
  568.                 DoShowInfo();
  569.                 break;
  570.             case InfoReply_ID:
  571.                 DoSend(InfoAmiMsg);
  572.                 break;
  573.             case MainReply_ID:
  574.                 am=GetSelAmiMsg();
  575.                 if(am) DoSend(am);
  576.                 break;
  577.             case MainSend_ID:
  578.                 DoSend(NULL);    
  579.                 break;
  580.             case ClearList_ID:
  581.                 DoClearList();
  582.                 break;
  583.        }
  584.  
  585.        if (running && signals) Wait(signals|MyPortSig);
  586.     }
  587.     
  588.     if(App) DisposeObject(App);
  589.     
  590.     exit(0);
  591. }
  592.  
  593.